package com.shoeHouse.orderEvaluate.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shoeHouse.commodityInfo.model.CommodityInfo;
import com.shoeHouse.orderEvaluate.model.OrderEvaluate;
import com.shoeHouse.orderEvaluate.service.OrderEvaluateService;
import com.shoeHouse.user.model.UserInfo;
import com.shoeHouse.util.DataGrid;
import com.shoeHouse.util.IdWork;
import com.shoeHouse.util.PageHelper;
import com.shoeHouse.util.ResultInfo;
@Controller
@RequestMapping("/OrderEvalute")
public class OrderEvaluteAction {
	@Autowired
	private OrderEvaluateService evaluateService;
	
	
	/**
	 * 跳到回复页面
	 * 
	 */
	
	@RequestMapping("/forwordReply")
	public String forwordReply(String id, Map<String, Object> map){
		OrderEvaluate orderEvaluate=new OrderEvaluate();
		orderEvaluate.setId(id);
		OrderEvaluate evaluate=evaluateService.getSingle(orderEvaluate);
		map.put("model",evaluate);
		
		return "/pages/orderEvalute/save.jsp";
		
		
		
	}
	
	/**
	 * 回复评价
	 */
	@ResponseBody
	@RequestMapping("/reply")
   public ResultInfo reply(OrderEvaluate orderEvaluate,HttpSession session){
	 
	  
	   
	   
	   evaluateService.update(orderEvaluate);
	   ResultInfo info=new ResultInfo();
	   info.setSuccess(0);
	   return info;
   }
	@RequestMapping("/index")
	public String index(){
		
		return "/pages/orderEvalute/list.jsp";
	}
	@ResponseBody
	@RequestMapping("/view")
	public DataGrid view(HttpSession session,HttpServletRequest request,HttpServletResponse response,Integer page,Integer rows){
		UserInfo userInfo=(UserInfo) session.getAttribute("userInfo");
		//page表示当前页，rows表示一次查询的条数
		PageHelper pageHelper=new PageHelper();
		pageHelper.setCurrentPage(page);
		pageHelper.setPageSize(rows);
		//查询总数
		   DataGrid dataGrid=new DataGrid();
		OrderEvaluate orderEvaluate=new OrderEvaluate();
		orderEvaluate.setSellerId(userInfo.getId());
		List<OrderEvaluate> list=evaluateService.getAll(request,orderEvaluate, pageHelper);
		int count=evaluateService.count();
		dataGrid.setTotal(count);
		dataGrid.setRows(list);

		return dataGrid;
			
			
			
		}
		
	
	
}
